package com.fce.boc.service;

import com.fce.boc.bean.ReturnMsg;
import com.fce.boc.exception.ErrorCodeAndMsg;
import com.fce.boc.mapper.AccumulatedTransactionMapper;
import com.fce.boc.bean.AccumulateTransaction;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wenzhuo
 * @create 2023-10-18 2023/10/18
 */
@Service
public class AccumulatedTransactionService {

    @Resource
    private AccumulatedTransactionMapper accumulatedMapper;

    public ReturnMsg getAccumulated(){
        List<AccumulateTransaction> list = accumulatedMapper.getAccumulatedList();
        if(list.isEmpty()){
            return ReturnMsg.error(ErrorCodeAndMsg.DATA_NOT_EXIST);
        }

        return  ReturnMsg.success().setData(list);
    }


    public ReturnMsg addAccumulated(AccumulateTransaction accumulated){
        if(accumulatedMapper.addAccumulated(accumulated) <= 0){
            return ReturnMsg.error(ErrorCodeAndMsg.DATA_NOT_EXIST);
        }

        return  ReturnMsg.success();
    }
}
